﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.CompsitePattern.BasicCode.Abstract
{
    /// <summary>
    /// 抽象的部分
    /// (注-组合模式：透明模式，在此抽象类里加Add和Remove)
    /// </summary>
    public abstract class AbstractComponent
    {
        protected string _name;

        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="name"></param>
        public AbstractComponent(string name)
        {
            _name = name;
        }

        /// <summary>
        /// 添加叶子节点
        /// </summary>
        /// <param name="component"></param>
        public abstract void Add(AbstractComponent component);

        /// <summary>
        /// 删除叶子节点
        /// </summary>
        /// <param name="component"></param>
        public abstract void Remove(AbstractComponent component);

        /// <summary>
        /// 显示部分与整体的层次结构
        /// </summary>
        /// <param name="depth">深度</param>
        public abstract void Display(int depth);
    }
}
